<%@page import="com.yymmarket.forum.user.UserBean,com.yymmarket.forum.cache.ForumCache,com.yymmarket.forum.util.SessionUtil,com.yymmarket.util.StringUtil,com.yymmarket.framework.PagingBean,java.util.*,com.yymmarket.forum.chat.*,com.yymmarket.framework.WebAction"%><%@ 
page contentType="text/vnd.wap.wml;charset=utf-8"%><%
response.setHeader("Cache-Control","no-cache");
WebAction webAction = new WebAction(request,response);

Integer uid = SessionUtil.getSessionUserId(request);

UserBean userBean = ForumCache.getUser(uid);

ChatService chatService = ChatService.getInstance();
int hides = webAction.getParameterIntS("hide");
if(userBean != null) {
	if(hides==0||hides==1) {
		userBean.getUserStatBean().setHide(hides);
	}
}
int hide = 0;
if(userBean != null)
	hide = userBean.getUserStatBean().getHide();
int p1 = webAction.getParameterInt("p1");
int p = webAction.getParameterInt("p");
%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="聊天大厅" ontimer="<%=response.encodeURL("chat.jsp")%>">
<timer value="500"/>
<p><%if(userBean != null) {%>
==聊天记录==<br/><%
int count1 = chatService.getCountUserChats(uid);

int limit1 = 5;
int start1 = p1 * limit1;
List<ChatBean> list1 = chatService.getUserChats(uid,start1,limit1);
PagingBean paging1 = new PagingBean(webAction,count1,limit1,"p1");
int i1 = 1;
for(ChatBean chat:list1) {
%><%=p1*limit1+i1
%>.<a href="<%=response.encodeURL("newChat.jsp?toId="+chat.getFromId())%>"><%= StringUtil.toWml(chat.getFromUser())%></a>:<%
if( chat.getToId()>0)
{	
%><a href="<%=response.encodeURL("newChat.jsp?toId="+chat.getToId())%>"><%= StringUtil.toWml(chat.getToUser())%></a>,<%
}
%><%=StringUtil.toWml(chat.getContent())%>(<%=chat.getCreateTime() %>)<br/>
<%i1++;} 
%><%=paging1.shuzifenyeAndShangXia(response.encodeURL("chat.jsp?p="+p),true,"|",response) %><%} %>
==聊天大厅[<%if(hide==0) {%><a href="chat.jsp?hide=1">隐藏</a><%}else {%><a href="chat.jsp?hide=0">显示</a><%} %>]==<br/><%
if(hide==0) {
	int count = chatService.getAllCount();
	
	int limit = 5;
	int start = p * limit;

	List<ChatBean> list = chatService.getAllChats(start,limit);
	PagingBean paging = new PagingBean(webAction,count,limit,"p");
%><%
if(uid>0) {%>[<a href="<%=response.encodeURL("newChat.jsp") %>">发言</a>]<%} %>[<a href="<%=response.encodeURL("chat.jsp") %>">刷新</a>]<br/><%
int i = 1;
for(ChatBean chat:list) {
%><%=p*limit+i
%>.<a href="<%=response.encodeURL("newChat.jsp?toId="+chat.getFromId())%>"><%= StringUtil.toWml(chat.getFromUser())%></a>:<%
if( chat.getToId()>0)
{	
%><a href="<%=response.encodeURL("newChat.jsp?toId="+chat.getToId())%>"><%= StringUtil.toWml(chat.getToUser())%></a>,<%
}
%><%=StringUtil.toWml(chat.getContent())%>(<%=chat.getCreateTime() %>)<br/>
<%i++;} %><%
if(paging.getCurrentPageIndex()+1<paging.getTotalPageCount()) {%>
<a href="<%=response.encodeURL("chat.jsp?p1="+p1+"&amp;"+"p="+(paging.getCurrentPageIndex()+1)) %>">下页</a><%
} 
if(paging.getCurrentPageIndex()>0) {
%><a href="<%=response.encodeURL("chat.jsp?p1="+p1+"&amp;"+"p="+(paging.getCurrentPageIndex()-1)) %>">上页</a><%
} %><br/><%=paging.shuzifenye(response.encodeURL("chat.jsp?p1="+p1),true,"|",response) %><%} 
%></p>
</card>

</wml>